﻿
//切换Tab 第一个参数:标签的总Id,系统自动Id查找其下所有li标签，第二个参数：需要显示内容的Name
var CSP_Tabs = {
    TabChangingOver: function (tabId, contentName) {
        var that = this;
        var lis = $("#" + tabId).find("li");

        $.each(lis, function (index, data) {
            $(data).bind("mouseenter", function () {
                that.CancelCurrent(tabId, contentName);
                var className = $(this).attr("class");
                var className = "";
                if ($(this).attr("class") != undefined) {
                    className = $(this).attr("class");
                }
                $(this).attr("class", className + " current");
                $("[name=" + contentName + "]").eq(index).show();
            });
        });
    },
    CancelCurrent: function (tabId, contentName) {
        var lis = $("#" + tabId).find("li");
        $("[name=" + contentName + "]").hide();
        $.each(lis, function (index, data) {
            var className = "";
            if ($(data).attr("class") != undefined) {
                className = $(data).attr("class").replace(" current", "").replace("current", "");
            }

            $(data).attr("class", className);
        });
    }
}

$().ready(function () {
    CSP_Tabs.TabChangingOver('RecommendCurriculum', 'RecommendCurriculum');
    CSP_Tabs.TabChangingOver('RecommendCurriculum1', 'RecommendCurriculum1');
    CSP_Tabs.TabChangingOver('ChildrenTalent', 'ChildrenTalent');
    CSP_Tabs.TabChangingOver('ChildrenSports', 'ChildrenSports');
    CSP_Tabs.TabChangingOver('Train', 'Train');
    CSP_Tabs.TabChangingOver('FamilyEducation', 'FamilyEducation');

    $("#J_ImgPosition").find("li").bind("mouseenter", function () {
        ShowImage(this);
    });
});

function ShowImage(obj) {
    $(obj).parent().find("li").attr("class", "");
    $(obj).addClass("ks-active");
    $("#J_Slide").find(".ks-switchable-content").find("li").hide();
    $("#J_Slide").find(".ks-switchable-content").find("li").eq([parseInt($(obj).html()) - 1]).show();
}

var QrCodePreview = function () {

    $("#QrCode").bind("mouseenter", function (e) {
        $("body").append("<p ><img id='preview' src='" + this.src + "' style='z-index:999' alt='微信' /></p>");
        var parm = { "top": $(this).offset().top, "left": $(this).offset().left - $(this).width() - $("#preview").width() };
        $("#preview").offset(parm);
    });
    $("#QrCode").bind("mouseleave", function (e) {
        $("#preview").remove();
    });
};

$(document).ready(function () {
    QrCodePreview();
});